package com.hehua.FlyweightPatternTwo;

public class Client {
    public static void main(String[] args) {
        IgoChessman black1,black2,black3,white1,white2;
        IgoChessmanFactory factory;

        /**
         * 获取享元对象
         */
        factory = IgoChessmanFactory.getInstance();

        /**
         * 通过享元工厂获取三颗黑子
         */
        black1 = factory.getIgoChessman("b");
        black2 = factory.getIgoChessman("b");
        black3 = factory.getIgoChessman("b");
        System.out.println("判断俩颗黑子是否相同"+(black1==black2));

        white1 = factory.getIgoChessman("w");
        white2 = factory.getIgoChessman("w");
        System.out.println("判断俩颗白字是否相同"+(white1==white2));

        black1.disPlay(new Coordinates(1,2));
        black2.disPlay(new Coordinates(3,4));
        black3.disPlay(new Coordinates(1,3));
        white1.disPlay(new Coordinates(2,5));
        white2.disPlay(new Coordinates(2,4));

    }
}
